package com.bbg.amyam.process.schedule;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import com.bbg.amyam.process.schedule.worker.Worker;

/**
 * Scheduler for handling jobs
 */
@Service
public class SchedulerHourlyService {

	protected static Logger logger = Logger.getLogger("service");

	@Autowired
	@Qualifier("passwordRetrieveKeyCleanupWork")
	private Worker passwordRetrieveKeyCleanupWork;

	/**
	 * You can opt for cron expression or fixedRate or fixedDelay
	 * <p>
	 * See Spring Framework 3 Reference: Chapter 25.5 Annotation Support for
	 * Scheduling and Asynchronous Execution
	 */
	// @Scheduled(fixedDelay=60000)
	@Scheduled(fixedRate = 3600000)
	// @Scheduled(cron="*/5 * * * * ?")
	public void doSchedule() {
		logger.debug("Start schedule");

		passwordRetrieveKeyCleanupWork.work();

		logger.debug("End schedule");
	}

}
